package br.ufmg.dees.insane.analysisModel;

import java.util.ArrayList;

import br.ufmg.dees.insane.util.IMatrix;
import br.ufmg.dees.insane.util.IVector;

public class Line_2D extends Line {

	private static final long serialVersionUID = 1L;

	@Override
	protected int getNdf() {
		return 2;
	}

	@Override
	protected IVector getNormalVector(IMatrix a, IMatrix b) {
		int nNos = (a.getNumCol());
		IVector normal = new IVector(2);
		IVector vectorX = new IVector(nNos);
		IVector vectorY = new IVector(nNos);
		IVector n_Xi = new IVector(nNos);
		
		normal.zero();
		vectorX.zero();
		vectorY.zero();
		n_Xi.zero();
		
		for(int i = 0; i < nNos; i++)
		{
			vectorX.setElement(i,b.getElement(2*i,0));
			vectorY.setElement(i,b.getElement(2*i+1,0));
		}
		
		a.getRow(0,n_Xi);
		
		double dX_dXi = n_Xi.dot(vectorX);
		double dY_dXi = n_Xi.dot(vectorY);
		double dXi_dS = 1/(Math.sqrt((dX_dXi*dX_dXi)+(dY_dXi*dY_dXi)));
		
		normal.setElement(0,(dX_dXi*dXi_dS));
		normal.setElement(1,(dY_dXi*dXi_dS));
		
		return normal;
	}

	public String getLabel() {
		return "Line_2D";
	}

	public ArrayList getDOFLabels() {
		// TODO Auto-generated method stub
		return null;
	}

	public IMatrix getPMatrix() {
		// TODO Auto-generated method stub
		return null;
	}

}
